﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_Bg : Command
    {
        public string bgName
        {
            get
            {
                return Value1;
            }
            set
            {
                Value1 = value;
            }
        }
        public float duration
        {
            get
            {
                float result = float.TryParse(Value2, out result) ? result : 0.5f;
                return result;
            }
            set
            {
                Value2 = value.ToString();
            }
        }
        public Vector3 position
        {
            get
            {
                return StringToVector3(Value3);
            }
            set
            {
                Value3 = Vector3ToString(value);
            }
        }
        public Vector2 scale
        {
            get
            {
                return StringToVector2(Value4);
            }
            set
            {
                Value4 = Vector2ToString(value);
            }
        }
        public string transitionRef
        {
            get
            {
                return Value5;
            }
            set
            {
                Value5 = value;
            }
        }
        public Ease easeType
        {
            get
            {
                return Enum.TryParse(Value6, out Ease ease) ? ease : Ease.Linear;
            }
            set
            {
                Value6 = value.ToString();
            }
        }
        public Command_Bg()
        {
            CommandType = COMMANDTYPE.Bg;
            bgName = "请输入背景名";
            duration = 0.5f;
            position = new Vector3 { x = 0, y = 0, z = 0 };
            scale = new Vector2 { x = 1, y = 1 };
            transitionRef = "中心向四周";
            easeType = Ease.Linear;
            Wait = true;
        }
        public Command_Bg(string BgName, float Duration, Vector3 Position, Vector2 Scale, string TransitionRef, Ease EaseType = Ease.Linear)
        {
            CommandType = COMMANDTYPE.Bg;
            bgName = BgName;
            duration = Duration;
            position = Position;
            scale = Scale;
            transitionRef = TransitionRef;
            easeType = EaseType;
            Wait = true;
        }
        public override string ToString()
        {
            return CommandType.ToString() + ":\n" + "显示背景:" + bgName;
        }
    }
}
